<?php
/**
 * Created by IntelliJ IDEA.
 * User: luwei
 * Date: 2017/12/6
 * Time: 9:36
 */
defined('IN_IA') or exit('Access Denied');
error_reporting(0);

//1.1.1
pdo_query("alter table zjhj_wdds_apps add column sms_type smallint(2) default 1;");
pdo_query("alter table zjhj_wdds_apps add column storage_type smallint(2) default 1;");
pdo_query("alter table zjhj_wdds_apps add column oss_key varchar(80) default '';");
pdo_query("alter table zjhj_wdds_apps add column oss_secret varchar(80) default '';");
pdo_query("alter table zjhj_wdds_apps add column oss_domain varchar(120) default '';");
pdo_query("alter table zjhj_wdds_apps add column oss_bucket varchar(50) default '';");
pdo_query("alter table zjhj_wdds_apps add column oss_endpoint varchar(120) default '';");

//1.1.2
pdo_query("alter table zjhj_wdds_apps add column alipay_type smallint(2) default 1;");
pdo_query("alter table zjhj_wdds_apps add alipay_max_amount decimal(10, 2) default 1000.00;");
pdo_query("alter table zjhj_wdds_apps add descrip varchar(120) default '';");

//1.1.3
pdo_query("alter table zjhj_wdds_apps add share_img varchar(150) default '';");


//1.1.5
pdo_query("CREATE TABLE `zjhj_wdds_messages` (`id` int(11) NOT NULL AUTO_INCREMENT,`content` varchar(150) COLLATE utf8_unicode_ci DEFAULT '',`app_id` int(11) DEFAULT 0,`user_id` int(11) DEFAULT 0,`order_id` int(11) DEFAULT 0,`types` smallint(2) DEFAULT 0,`status` smallint(2) DEFAULT 0,`amount_log_id` int(11) DEFAULT 0,`created_at` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',`updated_at` int(10) NOT NULL DEFAULT '0' COMMENT '修改时间',PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
pdo_query("CREATE TABLE `zjhj_wdds_amount_logs` (`id` int(11) NOT NULL AUTO_INCREMENT,`app_id` int(11) DEFAULT 0,`rate` int(10) unsigned DEFAULT 0,`total_amount` decimal(10, 2) DEFAULT 0.00,`amount` decimal(10, 2) DEFAULT 0.00,`shop_id` int(11) DEFAULT 0,`order_id` int(11) DEFAULT 0,`pay_types` smallint(2) default 1,`status` smallint(2) DEFAULT 0,`payed_at` int(10) DEFAULT 0,`created_at` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
pdo_query("CREATE TABLE `zjhj_wdds_dailytask_logs` (`id` int(11) NOT NULL AUTO_INCREMENT,`status` smallint(2) DEFAULT 0,`created_at` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");

//1.1.5
pdo_query("alter table zjhj_wdds_apps add audit_types smallint(2) default 1;");
pdo_query("alter table zjhj_wdds_apps add receive_days smallint(2) default 7;");
pdo_query("alter table zjhj_wdds_apps add aftersale_days smallint(2) default 7;");
pdo_query("alter table zjhj_wdds_apps add wxpay_cert text default '';");
pdo_query("alter table zjhj_wdds_orders add refund_id VARCHAR(100) default '';");
pdo_query("alter table zjhj_wdds_shops add amount decimal(10, 2) DEFAULT 0.00;");
pdo_query("alter table zjhj_wdds_orders add refund_reason VARCHAR(100) default '';");
pdo_query("alter table zjhj_wdds_apps add wxpay_key text default '';");
pdo_query("alter table zjhj_wdds_apps add link varchar(150) default '';");

//1.1.5
pdo_query("alter table zjhj_wdds_apps add refund_reject_template_id varchar(100) default '';");
pdo_query("alter table zjhj_wdds_shops add wxpay_account varchar(30) DEFAULT NULL;");
pdo_query("alter table zjhj_wdds_orders add refund_reject_reason VARCHAR(100) default null;");
pdo_query("alter table zjhj_wdds_apps add shop_login_logo varchar(150) default '';");
pdo_query("alter table zjhj_wdds_apps add smsct_refundcode varchar(100) COLLATE utf8_unicode_ci DEFAULT '';");

//1.1.6
pdo_query("alter table zjhj_wdds_apps add smsct_zanwincode varchar(100) COLLATE utf8_unicode_ci DEFAULT '';");
pdo_query("alter table zjhj_wdds_apps add qiniu_secretkey varchar(80) default '';");
pdo_query("alter table zjhj_wdds_apps add qiniu_accesskey varchar(80) default '';");
pdo_query("alter table zjhj_wdds_apps add qiniu_domain varchar(120) default '';");
pdo_query("alter table zjhj_wdds_apps add qiniu_bucket varchar(50) default '';");
pdo_query("alter table zjhj_wdds_orders add is_notify smallint(2) default 0;");
pdo_query("alter table zjhj_wdds_shops add threshold decimal(10, 2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_shops add threshold_rebate decimal(10, 2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_shops add is_threshold smallint(2) default 0;");

//1.1.7
pdo_query("alter table zjhj_wdds_amount_logs add tran_no varchar(80);");
pdo_query("alter table zjhj_wdds_amount_logs add payment_no varchar(80);");

//1.1.8
pdo_query("alter table zjhj_wdds_apps add pay_to_shop_template_id varchar(80) default '';");
pdo_query("alter table zjhj_wdds_orders add threshold_rebate decimal(10, 2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_adverts add shop_id int(11) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_adverts add product_id int(11) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_adverts add types smallint(2) default 0;");
pdo_query("alter table zjhj_wdds_apps add withdraw_min_amount decimal(10, 2) default 10;");
pdo_query("alter table zjhj_wdds_apps add withdraw_daily_times int(11) DEFAULT 1;");
pdo_query("alter table zjhj_wdds_apps add withdraw_is_auto smallint(2) default 0;");
pdo_query("alter table zjhj_wdds_shops add unbilled_amount decimal(10, 2) default 0;");
pdo_query("alter table zjhj_wdds_products add zan_status smallint(2) default 0;");
pdo_query("alter table zjhj_wdds_apps add company_name varchar(30) default '';");
pdo_query("alter table zjhj_wdds_orders add threshold decimal(10, 2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_amount_logs add form_id varchar(80)  default '';");

//1.1.9
pdo_query("alter table zjhj_wdds_products add proxy_price decimal(10, 2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_products add pf_id int(11) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_products add is_platform smallint(2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_products add update_at int(11) DEFAULT NULL;");
pdo_query("alter table zjhj_wdds_products add app_id int(11) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_product_cates add app_id int(11) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_product_cates add is_platform smallint(2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_orders add app_id int(11) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_orders add is_platform smallint(2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_order_children add proxy_price decimal(10, 2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_shops add brokerage decimal(10, 2) DEFAULT 0;");

pdo_query("CREATE TABLE `zjhj_wdds_brokerage_logs` (`id` int(11) NOT NULL AUTO_INCREMENT,`amount` decimal(10, 2) DEFAULT 0,`shop_id` int(11) DEFAULT 0,`app_id` int(11) DEFAULT 0,`order_id` int(11) DEFAULT 0,`created_at` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
pdo_query("alter table zjhj_wdds_amount_logs add types smallint(2) DEFAULT 1;");
pdo_query("CREATE TABLE `zjhj_wdds_history_logs` (`id` int(11) NOT NULL AUTO_INCREMENT,`shop_id` int(11) DEFAULT 0,`user_id` int(11) DEFAULT 0,`updated_at` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
pdo_query("alter table zjhj_wdds_order_children add product_logo varchar(150) default '';");
pdo_query("CREATE TABLE `zjhj_wdds_helps` (`id` int(11) NOT NULL AUTO_INCREMENT,`title` varchar(30) NOT NULL DEFAULT '' COMMENT '使用帮助标题',`content` text NOT NULL DEFAULT '' COMMENT '使用帮助内容',`status` smallint(2) DEFAULT 0 COMMENT '使用帮助状态',`app_id` int(11) DEFAULT 0,`orderby` int(10) NOT NULL DEFAULT '99' COMMENT '排序',`created_at` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',`updated_at` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
pdo_query("alter table zjhj_wdds_apps add qiniu_area smallint(2) default 1;");
pdo_query("alter table zjhj_wdds_shops add announcement varchar(120) NOT NULL default '' COMMENT '店铺公告';");
pdo_query("update `zjhj_wdds_shops` set layout=1;");

//1.2.0
pdo_query("alter table zjhj_wdds_shops add products_limit smallint default 0 COMMENT '商品数量限制，默认0不限制';");
pdo_query("alter table zjhj_wdds_shops add product_cates_limit smallint default 0 COMMENT '商品分类数量限制，默认0不限制';");
pdo_query("alter table zjhj_wdds_apps add alipay_switch smallint(2) default 0 COMMENT '是否开启支付宝提现，默认0，不开启';");

//1.2.1
pdo_query("alter table zjhj_wdds_amount_logs add reject_reason VARCHAR(100) NOT NULL default '' COMMENT '拒绝提现理由';");
pdo_query("alter table zjhj_wdds_products add is_not_return smallint(2) DEFAULT 0  COMMENT '是否不支持7天无理由退款，默认0支持';");
pdo_query("alter table zjhj_wdds_products add is_limit smallint DEFAULT 0  COMMENT '商品限购，默认0，不限制';");
pdo_query("alter table zjhj_wdds_products add descrip varchar(120) NOT NULL default '' COMMENT '商品库的海报介绍';");
pdo_query("alter table zjhj_wdds_apps add withdraw_reject_template_id varchar(80) default '';");
pdo_query("alter table zjhj_wdds_helps add types smallint(1) default 1;");

//1.2.3
pdo_query("alter table zjhj_wdds_orders add delivery_free decimal(10, 2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_shops add kfphone varchar(120) NOT NULL default '' COMMENT '客服电话';");
pdo_query("alter table zjhj_wdds_shops add delivery_free decimal(10, 2) DEFAULT 0;");
pdo_query("alter table zjhj_wdds_apps add withdraw_max_amount decimal(10, 2) default 19999;");

pdo_query("alter table zjhj_wdds_shops add `lib_status` int(10) NOT NULL DEFAULT '1' COMMENT '商品库状态:1启用 2禁用';");
pdo_query("alter table zjhj_wdds_apps add `index_types` smallint(2) NOT NULL DEFAULT '1' COMMENT '首页模式:1默认 2优选';");
pdo_query("alter table zjhj_wdds_apps add `hot_title` varchar(30) NOT NULL DEFAULT '小店优选' COMMENT '小店优选主标题';");
pdo_query("alter table zjhj_wdds_adverts add `desc` varchar(80) DEFAULT NULL COMMENT '优选商品描述';");

//1.3.3
pdo_query("ALTER TABLE `zjhj_wdds_products` ADD COLUMN `product_num`  int(11) NULL DEFAULT 0 COMMENT '商品库存';");
pdo_query("ALTER TABLE `zjhj_wdds_products` ADD COLUMN `limit_depot`  int(11) NULL DEFAULT 0 COMMENT '限时入库/时';");
pdo_query("ALTER TABLE `zjhj_wdds_adverts` ADD COLUMN `appid`  varchar(100) NULL DEFAULT NULL COMMENT '跳转appid', ADD COLUMN `is_applet`  int(11) NULL DEFAULT 0 AFTER `appid`;");

//1.3.4
pdo_query("ALTER TABLE `zjhj_wdds_specs` ADD COLUMN `stock`  int(11) NULL DEFAULT 0 COMMENT '库存';");
pdo_query("ALTER TABLE `zjhj_wdds_order_children` ADD COLUMN `spec_id`  int(11) NULL DEFAULT 0;");
pdo_query("CREATE TABLE `zjhj_wdds_mode` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `openid` varchar(100) DEFAULT '' COMMENT '微信openid',
  `name` varchar(255) DEFAULT '',
  `url` varchar(255) DEFAULT NULL COMMENT '跳转地址',
  `pic` varchar(255) DEFAULT '',
  `order_id` int(11) DEFAULT '0' COMMENT '排序',
  `status` int(11) DEFAULT '0' COMMENT '0 显示 1 隐藏',
  `is_delete` int(11) DEFAULT '0' COMMENT '0 未删除 1 删除',
  `mode` int(11) DEFAULT '0' COMMENT '1：默认模式 2.小店优选',
  `appid` varchar(255) DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
pdo_query("INSERT INTO `zjhj_wdds_mode` VALUES ('1', '4', '浏览历史', '../index/history', null, '11', '0', '0', '1', '');");
pdo_query("INSERT INTO `zjhj_wdds_mode` VALUES ('2', '4', '登录小店', '../shop/login', null, '33', '0', '0', '1', '');");
pdo_query("INSERT INTO `zjhj_wdds_mode` VALUES ('3', '4', '用户中心', '../index/mypage', null, '22', '0', '0', '1', '');");
pdo_query("INSERT INTO `zjhj_wdds_mode` VALUES ('4', '4', '用户中心', '../index/mypage', null, '22', '0', '0', '2', '');");
pdo_query("INSERT INTO `zjhj_wdds_mode` VALUES ('5', '4', '申请小店', '../common/shop_form', null, '33', '0', '0', '2', '');");
pdo_query("INSERT INTO `zjhj_wdds_mode` VALUES ('6', '4', '登录小店', '../shop/login', null, '44', '0', '0', '2', '');");
pdo_query("INSERT INTO `zjhj_wdds_mode` VALUES ('7', '4', '浏览历史', '../index/history', null, '11', '0', '0', '2', '');");

//1.3.6
pdo_query("ALTER TABLE `zjhj_wdds_apps` ADD COLUMN `is_search`  int(10) NULL DEFAULT 0 COMMENT '是否隐藏搜索框' AFTER `hot_title`;");
